package hutech.ksv.model;

import hutech.ksv.entity.QuanAnEntity;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class QuanAnDataModel extends ListDataModel<QuanAnEntity> implements
		SelectableDataModel<QuanAnEntity> {

	public QuanAnDataModel() {

	}

	public QuanAnDataModel(List<QuanAnEntity> data) {
		super(data);
	}

	@Override
	public QuanAnEntity getRowData(String rowKey) {
		List<QuanAnEntity> quanan = (List<QuanAnEntity>) getWrappedData();

		for (QuanAnEntity c : quanan) {
			if (c.getQuanAnNumber() == Long.parseLong(rowKey)) {
				return c;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(QuanAnEntity nhatro) {
		return nhatro.getQuanAnNumber();
	}
}
